﻿namespace Gamelight.Graphics
{
	internal class RectangleDrawer
	{
		public void DrawRectangle(
			int[,] pixels,
			int[] column_affected,
			int[] min_y_affected,
			int[] max_y_affected,
			int counter,
			int left, int top, int right, int bottom)
		{
			if (left > right || top > bottom)
			{
				return;
			}

			if (left < 0) left = 0;
			if (top < 0) top = 0;

			int x, y;
			for (x = left; x <= right; ++x)
			{
				column_affected[x] = counter;
				min_y_affected[x] = top;
				max_y_affected[x] = bottom;
				for (y = top; y <= bottom; ++y)
				{
					pixels[x, y] = counter;
				}
			}
		}
	}
}
